package utils
{
	import flash.geom.Point;
	import flash.system.Capabilities;

	public class commonUtils
	{
		public function commonUtils()
		{
		}
		
		public static function inchesToPixels(inches:Number):Number
		{
			return Capabilities.screenDPI * (inches/1000);
		}
		public static function stringColorToHexColor(value:String):uint
		{
			var r:RegExp=new RegExp(/#/g);		
			var result:uint = uint(String(value).replace(r,"0x"));
			return result;
		}
		public static function stringDataToDrawData(value:String):String
		{
			var temp:Array = value.split("|");
			
			var result:String = "";
			for each(var item:* in temp){
				var itemArray:Array = item.split(",");
				result = result + inchesToPixels(Number(itemArray[0])) + "," + inchesToPixels(Number(itemArray[1])) + " ";
				//result = result + item + " ";  
			}
			return result;
		}
		
		public static function dataToPointRightData(value:String):Object
		{
			var temp:Array = value.split("|");
			var startPointArray:Array = temp[temp.length-1].split(",");
			var endPointArray:Array = temp[temp.length-2].split(",");
			var result:Object = {sx:startPointArray[0],sy:startPointArray[1],ex:endPointArray[0],ey:endPointArray[1]};
			return result;
		}
		
		public static function dataToPointLeftData(value:String):Object
		{
			var temp:Array = value.split("|");
			var startPointArray:Array = temp[0].split(",");
			var endPointArray:Array = temp[1].split(",");
			var result:Object = {sx:startPointArray[0],sy:endPointArray[1],ex:endPointArray[0],ey:startPointArray[1]};
			return result;
		}
	}
}